﻿package frEngine.shader.filters.fragmentFilters
{
    import baseEngine.core.*;
    import frEngine.manager.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;

    public class TextureFsFilter extends FilterBase
    {
        public var texture:Texture3D;
        private var _indexOfFs:int = 0;
        private var _fsName:String = "fs1";
        private var _buildName:String = "{texture2}";

        public function TextureFsFilter(param1:Texture3D, param2:int = 1)
        {
            super(FilterType.MaterialTexture1 + (param2 - 1), FilterPriority.fragment, [param1]);
            this.texture = param1;
            this.indexOfFs = param2;
            return;
        }// end function

        public function get indexOfFs() : int
        {
            return this._indexOfFs;
        }// end function

        public function set indexOfFs(param1:int) : void
        {
            if (param1 >= 0 && param1 < 8)
            {
                this._indexOfFs = param1;
                this._fsName = "fs" + param1;
                this._buildName = "{texture" + (param1 + 1) + "}";
            }
            else
            {
                throw new Error("超出最大个数8");
            }
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            param1.getParamByName(this._buildName, false).value = this.texture;
            return;
        }// end function

        override public function get programeId() : String
        {
            return "textureFsFilter:" + this._fsName + "_" + FilterBase.ATLFormat[this.texture.format] + ",mip:" + this.texture.mipMode;
        }// end function

        override public function clone() : FilterBase
        {
            var _loc_1:* = Resource3dManager.instance.getTexture3d(this.texture.request, this.texture.mipMode);
            var _loc_2:* = new TextureFsFilter(_loc_1);
            return _loc_2;
        }// end function

        override public function createFragmentUvCoord(param1:Program3dRegisterInstance) : String
        {
            var _loc_2:* = new Array();
            _loc_2.push(new ToBuilderInfo(this._fsName, this._buildName, false, 1, this.texture));
            var _loc_3:String = "";
            _loc_3 = param1.toBuild(_loc_3, _loc_2);
            return _loc_3;
        }// end function

    }
}
